<?php
/**
 * 项目长连接服务
 */
namespace app\worker\controller;

use think\worker\Server;
use Workerman\Lib\Timer;
 
error_reporting(E_ERROR | E_PARSE);
 
class Push extends Server
{
    protected $socket = 'websocket://0.0.0.0:8282'; 

    protected $connection;

    protected static $
    
    /**
     * 收到用户信息
     */
    public function onMessage($connection, $data)
    {
        // 客户端传递的是json数据
        $arrUserData = json_decode($data, true);
        if( !$arrUserData ){
            return ;
        }
        $connection->send('hello test');
    }

    public function onConnect($connection)
    {
      echo "new connection from ip " . $connection->getRemoteIp() . "\n";
    }

    public function onClose($connection)
    {
		      
    }

}